import { computed, reactive, Ref, ref } from "vue";

export default function InitHook(state: { activeKey: Ref<string> }) {
  const { activeKey } = state;
  //表单数据
  const formState = reactive({
    status: undefined //	状态
  });

  //表格数据
  const option = reactive([
    {
      label: "入仓",
      value: 5
    },
    {
      label: "出库",
      value: 6
    },
    {
      label: "出仓",
      value: 7
    },
    {
      label: "运输",
      value: 8
    }
  ]);
  const options = computed(() => {
    if (activeKey.value === "8")
      return [
        {
          label: "入仓",
          value: 5
        },
        {
          label: "出库",
          value: 6
        },
        {
          label: "出仓",
          value: 7
        }
      ];
    if (activeKey.value === "7")
      return [
        {
          label: "入仓",
          value: 5
        },
        {
          label: "出库",
          value: 6
        }
      ];
    if (activeKey.value === "6")
      return [
        {
          label: "入仓",
          value: 5
        }
      ];

    return option;
  });

  //等待状态
  const loading = ref<boolean>(false);

  //表单ref
  const formRef = ref(null);
  return {
    options,
    formState,
    loading,
    formRef
  };
}
